<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>查看所有商品</title>
</head>
<body>
    <button id="selectAllGoods">查看所有商品</button>

</body>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
    $("#selectAllGoods").click(
        function () {
            $.get("/goods/selectAll",{},function (goods) {
                var table = $("<table></table>");
                var thead = $("<tr>\n" +
                    "        <td>商品Id</td>\n" +
                    "        <td>商品名称</td>\n" +
                    "        <td>商品数量</td>\n" +
                    "        <td>商品价格</td>\n" +
                    "        <td>商品信息</td>\n" +
                    "    </tr>");
                table.append(thead);
                for (var i = 0; i < goods.length; i++){
                    console.log(goods[i]);
                    var good = goods[i];
                    var tbody = $("<tbody></tbody>");
                    var goodsId = $("<td>" + good.goodsId + "</td>");
                    var goodsName = $("<td>" + good.goodsName + "</td>");
                    var goodsCount = $("<td>" + good.goodsCount + "</td>");
                    var goodsPrice = $("<td>" + good.goodsPrice + "</td>");
                    var goodsInfo = $("<td>" + good.goodsInfo + "</td>");
                    tbody.append(goodsId);
                    tbody.append(goodsName);
                    tbody.append(goodsCount);
                    tbody.append(goodsPrice);
                    tbody.append(goodsInfo);
                    table.append(tbody);
                }
                $("body").append(table);
                // $("#selectAllGoods").remove();
                // var button = $("<a id=\"toSelectAllGoods\" href='selectAllGoods.html'>返回</a>");
                $("body").append(button);
            },"json");
        }
    );
</script>
</html>